package com.mzj.saas.mservice.area.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.area.repository.AreaSearchLogRepository;
import com.mzj.saas.mservice.area.service.AreaService;
import com.mzj.saas.mservice.house.vo.OrgVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 地区接口
 */
@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    /**
     * 查询城市，按字母返回
     * @param name
     * @return
     */
    @GetMapping(value ="/getCity")
    public ResultBean<Map<String,List<String>>> getCity(@RequestParam(required = false) String name){
        return areaService.getCity(name);
    }

    /**
     * 查询热门城市搜索
     * @return
     */
    @GetMapping(value ="/getHotCity")
    public ResultBean<List<AreaSearchLogRepository.AreaSearchLogCountVo>> getHotCity(){
        return areaService.getHotCity();
    }

    /**
     * 查询区域,实现了公租房资格申请列表不用数据的查询,自动显示在前端页面
     * @param parentId 区域父级id
     * @return
     * @throws Exception
     */
    @SuppressWarnings("rawtypes")
    @GetMapping(value ="/list")
    public ResultBean<List<Map>> list(@RequestParam Long parentId) throws Exception {
        return areaService.list(parentId);
    }

    /**
     * 查询定位城市区
     * @param cityName
     * @return
     */
    @GetMapping("/locationDistrict")
    @ResponseBody
    public ResultBean<List<Map<String, Object>>> locationDistrict(@RequestParam(value = "cityName") String cityName) {
        return areaService.locationDistrict(cityName);
    }

    /**
     * 查询城市信息
     * @param name
     * @return
     */
    @GetMapping(value ="/getCityByName")
    public ResultBean<Object> getCityByName(@RequestParam(required = false) String name){
        return areaService.getCityByName(name);
    }
    

}
